#!/usr/bin/env python
# Config ini handler
import inireader
import os,sys
from misc import *

config = {}

CONFIG_INI = "webwallpaper.ini"

_init_config = {
    "global" : {
        "OUTPUT_PATH" : ".\\wallpapers\\",
        "WIDE_SCREEN" : "0",
        "BING_REGION" : "random",
        "PROXY" : "",
        "LOGFILE" : "webwallpaper.log",
    }
}

def parse_configs():
    global config
    change_to_program_dir()

    reader = inireader.IniReader(CONFIG_INI, _init_config)
    config = reader.sections("global")

    config["OUTPUT_PATH"] = os.path.abspath(config["OUTPUT_PATH"])

    # Makedir is OUTPUT_PATH not exists
    if not os.path.isdir(config["OUTPUT_PATH"]):
        os.makedirs(config["OUTPUT_PATH"])

parse_configs()
